<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Planos de Discagem</title>
<link href="css/conf.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">

	function sectionTypeOnChange(){
	
		var combo = document.getElementById("sectionType");
		
		var general = document.getElementById("general");
		var globals = document.getElementById("globals");
		var outros = document.getElementById("outros");
		if (combo.value == "general" ) {
			general.style.display = "block";
			globals.style.display = "none";
			outros.style.display = "none";
			
			document.getElementById("id").value = "general";
		
		} else if (combo.value == "globals" ) {
			general.style.display = "none";
			globals.style.display = "block";
			outros.style.display = "none";
			
			document.getElementById("id").value = "globals";
			
		} else {
			general.style.display = "none";
			globals.style.display = "none";
			outros.style.display = "block";
			
			document.getElementById("id").value = "";
		}
	}

</script>

</head>

<body bgcolor="#c0c0c0">

	<div align="center">
		<h2>Configuração Extensions</h2>
		<h6>
			<a href="menu.jsp">Voltar ao Menu</a>
		</h6>
	</div>

	<form action='ExtensionsController' name='controle'>

		<table width="473" border="0" align="center"
			cellpadding="1" cellspacing="1">
			
			<tr>
				<td colspan="2"><span class="submenus">Tipo de Seção: </span>
					<select id="sectionType" name="sectionType" onchange="sectionTypeOnChange();">
						<c:choose>
								<c:when test="${empty obj || (! empty obj && obj.id == 'general')}">
								
									<option value="general" selected="selected">General</option>
									<option value="globals">Globals</option>
									<option value="">Outros</option>
									
									<c:set var="displayGeneral" value="block"></c:set>
									<c:set var="displayGlobals" value="none"></c:set>
									<c:set var="displayOutros" value="none"></c:set>
								
								</c:when>
								<c:when test="${empty obj || (! empty obj && obj.id == 'globals')}">
								
									<option value="general">General</option>
									<option value="globals" selected="selected">Globals</option>
									<option value="">Outros</option>
									
									<c:set var="displayGeneral" value="none"></c:set>
									<c:set var="displayGlobals" value="block"></c:set>
									<c:set var="displayOutros" value="none"></c:set>
								
								</c:when>
								<c:otherwise>
								
									<option value="general">General</option>
									<option value="globals" selected="selected">Globals</option>
									<option value=""  selected="selected">Outros</option>
								
									<c:set var="displayGeneral" value="none"></c:set>
									<c:set var="displayGlobals" value="none"></c:set>
									<c:set var="displayOutros" value="block"></c:set>
								
								</c:otherwise>
							</c:choose>
					</select>
				</td>
			</tr>
			
			<tr>
				<td colspan="2">
					<div id="general" style="display: ${displayGeneral};">
						<table>
							<tr>
								<td><span class="submenus">Static =</span></td>
								<td><span class="submenus"><input type='text' name='_static' id="_static" size="6"/></span></td>
							</tr>
							<tr>
								<td><span class="submenus">Write Protect =</span></td>
								<td><span class="submenus"><input type='text' name='writeProtect' id="writeProtect" size="6"/></span></td>
							</tr>
							<tr>
								<td><span class="submenus">Auto Fall Through =</span></td>
								<td><span class="submenus"><input type='text' name='autoFallThrough' id="autoFallThrough" size="6"/></span></td>
							</tr>
							<tr>
								<td><span class="submenus">Priority Jumping =</span></td>
								<td><span class="submenus"><input type='text' name='priorityJumping' id="priorityJumping" size="6"/></span></td>
							</tr>
						</table>
					</div>
				</td>
			</tr>
			
			<tr>
				<td colspan="2">
					<div id="globals" style="display: ${displayGlobals};">
						<table>
							<tr>
								<td><span class="submenus">Chave =</span></td>
								<td><span class="submenus"><input type='text' name='chaveGlobals' id="chaveGlobals" size="6"/></span></td>
							</tr>
							<tr>
								<td><span class="submenus">Valor =</span></td>
								<td><span class="submenus"><input type='text' name='valorGlobals' id="valorGlobals" size="6"/></span></td>
							</tr>
						</table>
					</div>
				</td>
			</tr>
			
			<tr>
				<td colspan="2">
					<div id="outros" style="display: ${displayOutros};">
						<table>
							<tr>
								<td><span class="submenus">Seção =</span></td>
								<td height="23"><span class="submenus">[ <input
										type='text' name='id' maxlength="6" size="6" id="id" /> ]
								</span></td>
							</tr>
							<tr>
								<td width="94" height="49"><span class="submenus">exten =&gt;</span></td>
								<td width="420"><span class="submenus"> <input
										type='text' name='numExtensao' id="numExtensao" size="6"/>
								,
								    <input type='text'
										name='prioridade' id="prioridade" size='2'/>
								,
								<input type='text'
										name='aplicacao' id="aplicacao" />
				                </span></td>
							</tr>
						</table>
					</div>
				</td>
			</tr>
				
			

			<tr>
				<td colspan="2" align="center" valign="bottom"><input type='submit'
					class="textoBolt" value='Confirmar' /></td>
			</tr>


		</table>

		<p>&nbsp;</p>

		<input type="hidden" name="act" id="act" value="${requestScope.act}" />

	</form>

	<table width="899" border="1" cellspacing="0" cellpadding="1"
		align="center" style="border: 1px thin solid;">
		
		<tr>
			<td colspan="4" style="background-color: lightgrey"><b>GENERAL</b></td>
		</tr>
		
		<tr class="texto" style="background-color: lightgrey">
			<td width="20%"><strong>Static</strong></td>
			<td width="20%"><strong>Write Protectc</strong></td>
			<td width="20%"><strong>Auto Fall Through</strong></td>
			<td width="20%"><strong>Priority Jumping</strong></td>
		</tr>
	
		<tbody>
			<c:forEach items="${requestScope.lista}" var="extension" >
			
				<c:if test="${! empty extension._static || ! empty extension.writeProtect || ! empty extension.autoFallThrough || ! empty extension.priorityJumping}">
					<tr>
						<td>${extension._static}</td>
						<td>${extension.writeProtect}</td>
						<td>${extension.autoFallThrough}</td>
						<td>${extension.priorityJumping}</td>
						
						<!-- <td width="52"><input name="Deletar2" type="submit" class="rodape" id="Deletar2" value="Alterar" /></td>
						<td width="56"><input name="Deletar" type="submit" class="rodape" id="Deletar" value="Deletar" /></td> -->
					</tr>
				</c:if>
				
			</c:forEach>
		</tbody>

	</table>
	
	<table width="899" border="1" cellspacing="0" cellpadding="1"
		align="center" style="border: 1px thin solid;">
		
		<tr>
			<td colspan="4" style="background-color: lightgrey"><b>GLOBALS</b></td>
		</tr>
		
		<tr class="texto" style="background-color: lightgrey">
			<c:forEach items="${requestScope.lista}" var="extension" >
				<c:if test="${! empty extension.globals}">
					<c:forEach items="${extension.globals}" var="global" >
						<td><strong>${global.chave}</strong></td>
					</c:forEach>
				</c:if>				
			</c:forEach>
		</tr>
		
		<tbody>
			<c:forEach items="${requestScope.lista}" var="extension" >
			
				<c:if test="${! empty extension.globals}">
					<tr>
						<c:forEach items="${extension.globals}" var="global" >
							<td>${global.valor}</td>
						</c:forEach>
					</tr>
				</c:if>	
			
			</c:forEach>
		</tbody>

	</table>
	
	<table width="899" border="1" cellspacing="0" cellpadding="1"
		align="center" style="border: 1px thin solid;">
		
		<tr>
			<td colspan="4" style="background-color: lightgrey"><b>SECTIONS</b></td>
		</tr>
		
		<tr class="texto" style="background-color: lightgrey">
			<td width="25%"><strong>Seção</strong></td>
			<td width="25%"><strong>Extensão</strong></td>
			<td width="25%"><strong>Prioridade</strong></td>
			<td width="25%"><strong>Aplicação</strong></td>
		</tr>		
		
		<tbody>
			<c:forEach items="${requestScope.lista}" var="extension" >
			
				<c:if test="${! empty extension.linhas}">
					<c:forEach items="${extension.linhas}" var="linha" >
						<tr>
							<td>${extension.id}</td>
							<td>${linha.numExtensao}</td>
							<td>${linha.prioridade}</td>
							<td>${linha.aplicacao}</td>
						</tr>
					</c:forEach>
				</c:if>	
			
			</c:forEach>
		</tbody>

	</table>
	
</body>

</html>
